package md.mru.core.domains.orders;

import md.mru.core.domains.*;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author sergiu.marin
 * @since 19.05.2014.
 */
@Entity
@Table(name = "orders", schema = "c##mru_optimized")
public class FolderOrder implements Serializable {

    private static final long serialVersionUID = 7429614107022548748L;

    @Id
    @Column(name = "id", unique = true, nullable = false, precision = 10, scale = 0)
    @GeneratedValue(generator = "orders_sequence")
    @SequenceGenerator(name = "orders_sequence", sequenceName = "orders_sequence", allocationSize = 1)
    private long id;
    @ManyToOne
    @JoinColumn(name = "order_type_id")
    private OrderType orderType;
    @Column(name = "order_number")
    private Integer orderNumber;
    @Column(name = "order_date")
    private Date orderDate;
    @Column(name = "from_date")
    private Date fromDate;
    @Column(name = "to_date")
    private Date toDate;
    @ManyToOne
    @JoinColumn(name = "issuer_id")
    private Issuer issuer;
    @ManyToOne
    @JoinColumn(name = "advancement_rank_id")
    private AdvancementRank advancementRank;
    private String ground;
    @Lob
    @Column(name = "order_text")
    private String orderText;
    @ManyToMany
    @JoinTable(name = "orders_folders", joinColumns = @JoinColumn(name = "order_id"),
            inverseJoinColumns = @JoinColumn(name = "folder_id"))
    private List<Folder> folders;
    @Column(name = "created_date")
    private Date createdDate;
    @Column(name = "trial_period")
    private Integer trialPeriod;
    @Column(name = "transfer_from")
    private String transferFrom;
    @Column(name = "doc_date")
    private Date docDate;
    @Column(name = "doc_number")
    private String docNumber;
    @Column(name = "education_institution_name")
    private String educationInstitutionName;
    private String location;
    @Column(name = "issued_by")
    private String issuedBy;
    private String reason;
    @Embedded
    private OrderCourse orderCourse;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public OrderType getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    public Integer getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(Integer orderNumber) {
        this.orderNumber = orderNumber;
    }

    public Date getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(Date orderDate) {
        this.orderDate = orderDate;
    }

    public Date getDocDate() {
        return docDate;
    }

    public void setDocDate(Date eventDate) {
        this.docDate = eventDate;
    }

    public Date getFromDate() {
        return fromDate;
    }

    public void setFromDate(Date fromDate) {
        this.fromDate = fromDate;
    }

    public Date getToDate() {
        return toDate;
    }

    public void setToDate(Date toDate) {
        this.toDate = toDate;
    }

    public Issuer getIssuer() {
        return issuer;
    }

    public void setIssuer(Issuer issuer) {
        this.issuer = issuer;
    }

    public AdvancementRank getAdvancementRank() {
        return advancementRank;
    }

    public void setAdvancementRank(AdvancementRank advancementRank) {
        this.advancementRank = advancementRank;
    }

    public String getGround() {
        return ground;
    }

    public void setGround(String notes) {
        this.ground = notes;
    }

    public String getOrderText() {
        return orderText;
    }

    public void setOrderText(String orderText) {
        this.orderText = orderText;
    }

    public List<Folder> getFolders() {
        if (folders == null) {
            folders = new ArrayList<>();
        }
        return folders;
    }

    public void setFolders(List<Folder> folders) {
        this.folders = folders;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public OrderCourse getOrderCourse() {
        return orderCourse;
    }

    public void setOrderCourse(OrderCourse orderCourse) {
        this.orderCourse = orderCourse;
    }

    public Integer getTrialPeriod() {
        return trialPeriod;
    }

    public void setTrialPeriod(Integer trialPeriod) {
        this.trialPeriod = trialPeriod;
    }

    public String getTransferFrom() {
        return transferFrom;
    }

    public void setTransferFrom(String transferFrom) {
        this.transferFrom = transferFrom;
    }

    public String getDocNumber() {
        return docNumber;
    }

    public void setDocNumber(String birthCertificateNo) {
        this.docNumber = birthCertificateNo;
    }

    public String getEducationInstitutionName() {
        return educationInstitutionName;
    }

    public void setEducationInstitutionName(String educationInstitutionName) {
        this.educationInstitutionName = educationInstitutionName;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public String getIssuedBy() {
        return issuedBy;
    }

    public void setIssuedBy(String issuedBy) {
        this.issuedBy = issuedBy;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

}
